import { createBrowserRouter, Navigate } from "react-router-dom";
import Layout from "../pages/Layout";
import Home from "../pages/home";
import About from "../pages/about";
import ErrorPage from "../pages/error";
import HomeList from "../pages/home/list";

const router = createBrowserRouter([
    {
        path: "/",
        element: <Layout />,
        children: [
            {
                path: "/",
                element: <Navigate to='/home' />,
            },
            {
                path: "home",
                element: <Home />,
                children: [
                    { index: true, element: <HomeList /> },
                    {
                        path: "list",
                        element: <HomeList />,
                        children: [
                            {
                                path: ":id",
                                element: (
                                    <div className='alert alert-danger'>
                                        详情
                                    </div>
                                ),
                            },
                        ],
                    },
                ],
            },
            {
                path: "about",
                element: <About />,
            },
        ],
    },
    {
        path: "*",
        element: <ErrorPage />,
    },
]);

export default router;
